#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define ff first
#define ss second 
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int inf = 1 << 28;
const ldb pi = fabsl(atan2l(0.0, -1.0));
using namespace std;

int n, m;
char **a;


void load()
{
	cin >> n >> m;
	a = new char *[n];
	for (int i = 0; i < n; i++)
		a[i] = new char [m + 2];

	nextLine();
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			a[i][j] = getchar();
		nextLine();
	}
}

const int mod = 1000003;

void die()
{
	printf("0");
	exit(0);
}

inline int leftness(char c)
{
	if (c == '1' || c == '2') return 0;
	if (c == '3' || c == '4') return 1;
	return -123123123;
}

inline int topness(char c)
{
	if (c == '1' || c == '4') return 0;
	if (c == '3' || c == '2') return 1;
	return -123123123;
}

void solve()
{
	int res = 1;
	for (int i = 0; i < n; i++)
	{
		int last = -1;
		for (int j = 0; j < m; j++)
		{
			if (a[i][j] == '.') continue;
			if (a[i][j] >= '0')
			{
				if (last != -1 && abs(leftness(a[i][last]) - leftness(a[i][j])) != abs((last - j) % 2))
					die();
				last = j;
			}
		}	
		if (last == -1)
		{
			res = (res * 2) % mod;
		}
	}

	for (int i = 0; i < m; i++)
	{
		int last = -1;
		for (int j = 0; j < n; j++)
		{
			if (a[j][i] == '.') continue;
			if (a[j][i] >= '0')
			{
				if (last != -1 && abs(topness(a[last][i]) - topness(a[j][i])) != abs((last - j) % 2))
					die();
				last = j;
			}
		}	
		if (last == -1)
			res = (res * 2) % mod;
	}
	cout << res;
}

#define file "c"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	load();
	solve();
	return 0;
}
